<?php

namespace iBrand\Component\Purchase\Models;

use iBrand\Shop\Core\Models\Clerk;
use iBrand\Shop\Core\Models\TakeStockPlan;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

class TakeStock extends Model implements Transformable
{
    use SoftDeletes, TransformableTrait;

    protected $guarded = ['id'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $prefix = config('ibrand.app.database.prefix', 'ibrand_');

        $this->setTable($prefix . 'store_take_stock');
    }

    public function items()
    {
        return $this->hasMany(TakeStockItem::class, 'take_stock_id');
    }

    public function clerk()
    {
        return $this->belongsTo(Clerk::class, 'clerk_id')->withDefault();
    }
}